package com.helmlabs.grouper.accounts.model;

import javax.persistence.Embeddable;

@Embeddable
public class Address {
	
	private String street1;
	private String street2;
	private String city;
	private String state;
	private String zipCode;
	private String country;

	public String getStreet1() {
		return street1;
	}
	public void setStreet1(String street1) {
		this.street1 = street1;
	}
	public String getStreet2() {
		return street2;
	}
	public void setStreet2(String street2) {
		this.street2 = street2;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getZipCode() {
		return zipCode;
	}
	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}
	public String getCountry() {
		return country;
	}
	public void setCountry(String country) {
		this.country = country;
	}
	public String toString(){
		StringBuffer buf = new StringBuffer();
		if (getStreet1()!=null && !"".equals(getStreet1())){
			buf.append(getStreet1());
			if (!"".equals(getStreet2()) || !"".equals(getCity()) || !"".equals(getState()) || !"".equals(getZipCode()))
				buf.append(", ");
		}
		
		if (getStreet2()!=null && !"".equals(getStreet2())){
			buf.append(getStreet2());
			if (!"".equals(getCity()) || !"".equals(getState()) || !"".equals(getZipCode()))
				buf.append(", ");
		}

		if (getCity()!=null && !"".equals(getCity())){
			buf.append(getCity());
			if (!"".equals(getState()) || !"".equals(getZipCode()))
				buf.append(", ");
		}

		if (getState()!=null && !"".equals(getState())){
			buf.append(getState());
			if (!"".equals(getZipCode()))
				buf.append(" ");
		}
		return buf.toString();
	}

}
